<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>ec: ec::TcpServer Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">ec
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>ec</b></li><li class="navelem"><a class="el" href="classec_1_1TcpServer.html">TcpServer</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#friends">Friends</a> &#124;
<a href="classec_1_1TcpServer-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">ec::TcpServer Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>TCP服务器  
 <a href="classec_1_1TcpServer.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="tcpServer_8h_source.html">tcpServer.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:acda2f66f003a4203c17886c3d70c1c77"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="acda2f66f003a4203c17886c3d70c1c77"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>TcpServer</b> (uint16_t threads=0)</td></tr>
<tr class="separator:acda2f66f003a4203c17886c3d70c1c77"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5bb66fcd67ba08031fc65c7e2ea7220d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpServer.html#a5bb66fcd67ba08031fc65c7e2ea7220d">setThreads</a> (uint16_t threads)</td></tr>
<tr class="separator:a5bb66fcd67ba08031fc65c7e2ea7220d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9249823c7fb037626df45335dad1c506"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classec_1_1Loop.html">ec::Loop</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpServer.html#a9249823c7fb037626df45335dad1c506">getLoop</a> () const </td></tr>
<tr class="separator:a9249823c7fb037626df45335dad1c506"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5664dc7c718dd2bd77a4f424ae49361f"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpServer.html#a5664dc7c718dd2bd77a4f424ae49361f">listen</a> (const char *ip, uint16_t port)</td></tr>
<tr class="memdesc:a5664dc7c718dd2bd77a4f424ae49361f"><td class="mdescLeft">&#160;</td><td class="mdescRight">监听  <a href="#a5664dc7c718dd2bd77a4f424ae49361f">More...</a><br/></td></tr>
<tr class="separator:a5664dc7c718dd2bd77a4f424ae49361f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad7312d86be0f2ad13d24de79c77298c3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpServer.html#ad7312d86be0f2ad13d24de79c77298c3">stop</a> ()</td></tr>
<tr class="separator:ad7312d86be0f2ad13d24de79c77298c3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad37edaf6e644d00b80c90610f4ca4ad5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpServer.html#ad37edaf6e644d00b80c90610f4ca4ad5">wait</a> ()</td></tr>
<tr class="separator:ad37edaf6e644d00b80c90610f4ca4ad5"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:aa70b8c0ff54b76b78492bd02c1396d40"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpServer.html#aa70b8c0ff54b76b78492bd02c1396d40">onListenError</a> ()</td></tr>
<tr class="separator:aa70b8c0ff54b76b78492bd02c1396d40"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afd151d6640eda1e7de6934292d0ce045"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpServer.html#afd151d6640eda1e7de6934292d0ce045">onSessionRead</a> (<a class="el" href="classec_1_1TcpSession.html">ec::TcpSession</a> *session)</td></tr>
<tr class="separator:afd151d6640eda1e7de6934292d0ce045"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6c6e9583952b194f6510b1d67c960682"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpServer.html#a6c6e9583952b194f6510b1d67c960682">onSessionDisconnected</a> (<a class="el" href="classec_1_1TcpSession.html">ec::TcpSession</a> *session)</td></tr>
<tr class="separator:a6c6e9583952b194f6510b1d67c960682"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3fb6ace162987df6f7375ef08346f8f8"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classec_1_1TcpServer.html#a3fb6ace162987df6f7375ef08346f8f8">onNewSession</a> (<a class="el" href="classec_1_1TcpSession.html">ec::TcpSession</a> *session)</td></tr>
<tr class="separator:a3fb6ace162987df6f7375ef08346f8f8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="friends"></a>
Friends</h2></td></tr>
<tr class="memitem:ad821fb654cf0b89cb6245fa831ec471c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad821fb654cf0b89cb6245fa831ec471c"></a>
class&#160;</td><td class="memItemRight" valign="bottom"><b>TcpSession</b></td></tr>
<tr class="separator:ad821fb654cf0b89cb6245fa831ec471c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aacbf5c26d9d3dde89d5ebccceb97ad3f"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aacbf5c26d9d3dde89d5ebccceb97ad3f"></a>
class&#160;</td><td class="memItemRight" valign="bottom"><b>TcpServerDispatcher</b></td></tr>
<tr class="separator:aacbf5c26d9d3dde89d5ebccceb97ad3f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>TCP服务器 </p>
<p>其包含了一个监听线程和多个IO线程 </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a9249823c7fb037626df45335dad1c506"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classec_1_1Loop.html">ec::Loop</a>&amp; ec::TcpServer::getLoop </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>获取Loop包含的Loop对象引用 </p>

</div>
</div>
<a class="anchor" id="a5664dc7c718dd2bd77a4f424ae49361f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool ec::TcpServer::listen </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>ip</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>port</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>监听 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ip</td><td>服务器IP地址 </td></tr>
    <tr><td class="paramname">port</td><td>服务器监听端口 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>返回是否成功 </dd></dl>

</div>
</div>
<a class="anchor" id="aa70b8c0ff54b76b78492bd02c1396d40"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void ec::TcpServer::onListenError </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>监听失败时处理接口 </p>

</div>
</div>
<a class="anchor" id="a3fb6ace162987df6f7375ef08346f8f8"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void ec::TcpServer::onNewSession </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classec_1_1TcpSession.html">ec::TcpSession</a> *&#160;</td>
          <td class="paramname"><em>session</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>有新连接时处理接口 </p>

</div>
</div>
<a class="anchor" id="a6c6e9583952b194f6510b1d67c960682"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void ec::TcpServer::onSessionDisconnected </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classec_1_1TcpSession.html">ec::TcpSession</a> *&#160;</td>
          <td class="paramname"><em>session</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>连接断开时处理接口 </p>

</div>
</div>
<a class="anchor" id="afd151d6640eda1e7de6934292d0ce045"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual void ec::TcpServer::onSessionRead </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classec_1_1TcpSession.html">ec::TcpSession</a> *&#160;</td>
          <td class="paramname"><em>session</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>连接有数据可读时处理接口 </p>

</div>
</div>
<a class="anchor" id="a5bb66fcd67ba08031fc65c7e2ea7220d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ec::TcpServer::setThreads </td>
          <td>(</td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>threads</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>设置IO线程数量，需在监听之前调用 </p>

</div>
</div>
<a class="anchor" id="ad7312d86be0f2ad13d24de79c77298c3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ec::TcpServer::stop </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>停止 </p>

</div>
</div>
<a class="anchor" id="ad37edaf6e644d00b80c90610f4ca4ad5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ec::TcpServer::wait </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>等待所有线程结束 </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>include/ec/<a class="el" href="tcpServer_8h_source.html">tcpServer.h</a></li>
<li>src/tcpServer.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Jul 3 2015 02:15:14 for ec by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>
